package com.tbm.impl.service;

import com.tbm.base.service.MenuService;
import com.tbm.entity.MenuEntity;
import com.tbm.repository.MenuEntityRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2017/8/30.
 */
@Service
public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuEntityRepository menuRepository;

    @Override
    public List<MenuEntity> findAll(Iterable<Integer> it) {
        return menuRepository.findAll(it);
    }

    @Override
    public List<MenuEntity> findAll(Example<MenuEntity> menuEntityExample){
        return menuRepository.findAll(menuEntityExample);
    }

    @Override
    public Page<MenuEntity> findAll(Pageable pageable) {
        return menuRepository.findAll(pageable);
    }

    @Override
    public List<MenuEntity> findByParentId(String parentId) {
        return menuRepository.findByParentId(parentId);
    }

    @Override
    public List<MenuEntity> findAll(){
        return menuRepository.findAll();
    }


    @Override
    public void save(MenuEntity menuEntity){
         menuRepository.save(menuEntity);
    }

    @Override
    public int count(){
        return (int) menuRepository.count();
    }
}
